#ifndef QUIZWINDOW_H
#define QUIZWINDOW_H

#include <QWidget>
#include <QRadioButton>
#include <QCheckBox>
#include <QAbstractButton>
#include <QLineEdit>
#include <QMessageBox>
#include <QShortcut>
#include "quiz.h"
#include "ftestywelcome.h"
#include "settingsdialog.h"
#include "aboutdialog.h"

namespace Ui {
    class QuizWindow;
}

class QuizWindow : public QWidget
{
    Q_OBJECT

public:
    explicit QuizWindow(QWidget *parent = 0);
    ~QuizWindow();
    void openQuiz(QString filename, int score, int penalty, bool ignoreSession);
    void show();
    void updateStats();

private:
    enum QuestionWindowType {
        SINGLE_ANSWER,
        MULTI_ANSWER,
        OPEN_ANSWER
    } questionType;
    Ui::QuizWindow *ui;
    Quiz quiz;

    QMap<QAbstractButton*, int> answerRadios;
    Question* currentQuestion;

    //! Stylesheet for highlighting correctly selected answer
    QString correctAnswerStylesheet;
    //! Stylesheet for highlighting the wrong answer
    QString badAnswerStylesheet;
    //! Stylesheet for highlighting the correct answer, that hadn't been selected
    QString correctUnselectedAnswerStylesheet;

    void displayRandomQuestion();
    bool* selectedAnswers;
    int initialAnswersN;
    void clearUI();
    void displayCurrentQuestion();
    void displayCurrentQuestionOne();
    void displayCurrentQuestionMany();
    void displayCurrentQuestionOpen();
    void selectAnswer(int ansId, bool isTrue);
    bool checkQuizAnswer();
    bool checkOpenAnswer();

private slots:

private slots:
    void on_openAnswerHintBtn_clicked();
    void on_btnHelp_clicked();
    void on_btnSettings_clicked();
    void on_btnSave_clicked();
    void on_btnCheck_clicked();
    void on_btnNextQuestion_clicked();
    void answerSelected(bool);
};

#endif // QUIZWINDOW_H
